/**
 * This class de
 */
package slhs.tempo.pivotTableUtilities;

import org.openswing.swing.wizard.client.WizardInnerPanel;
import org.openswing.swing.wizard.client.WizardPanel;

import slhs.tempo.scriptGenerator.UtilityConstants;

/**
 * ExecutionEngine.java
 * 
 * @author Swapnil Devikar
 * 
 */
public class ExecutionEngine {

    private static final String BLANK = "";

    /**
     * @param wizardPanel
     * @param pivotTableWizard
     */
    public ExecutionEngine(WizardPanel wizardPanel, PivotTableWizard pivotTableWizard) {
	String currentVisiblePanelId = wizardPanel.getCurrentVisiblePanel().getPanelId();
	WizardInnerPanel visiblePanel = wizardPanel.getCurrentVisiblePanel();

	if (currentVisiblePanelId.equals(PivotWizardFirstPanel.SCREEN_ID)) {
	    PivotWizardFirstPanel firstPanel = (PivotWizardFirstPanel) visiblePanel;
	    UtilityConstants.IS_OVERALL_ANALYSIS = firstPanel.isOverallAnalysisPerSubjectAcrossConditionsSelected();
	}
	/*
	 * Check if you're on second panel, if yes, do the statistical analysis and insert columns if the option is
	 * checked
	 */
	else if (currentVisiblePanelId.equals(PivotWizardSecondPanel.SCREEN_ID)) {
	    PivotWizardSecondPanel secondPanel = (PivotWizardSecondPanel) visiblePanel;
	    String tabId = secondPanel.saveCurrentState();
	    secondPanel.generateStats(tabId);
	    if (secondPanel.isInsertMeanChecked()) {
		secondPanel.insertStatsColumns();
	    }

	} else if (currentVisiblePanelId.equals(PivotWizardAnalysisPanel.SCREEN_ID)) {
	    // do nothing for now
	} else if (currentVisiblePanelId.equals(PivotWizardPostAnalysisFilterPanel.SCREEN_ID)) {
	    // Read all the user options here:
	    PivotWizardPostAnalysisFilterPanel fourthPanel = (PivotWizardPostAnalysisFilterPanel) visiblePanel;
	    if (!fourthPanel.getIgnoreNAboveMeanTime().equals(BLANK) && fourthPanel.getIgnoreNAboveMeanTime() != null) {
		Integer ignoreAboveMeanTimeValue = new Integer(fourthPanel.getIgnoreNAboveMeanTime());
	    }
	    if (!fourthPanel.getIgnoreNBelowMeanTime().equals(BLANK) && fourthPanel.getIgnoreNBelowMeanTime() != null) {
		Integer ignoreBelowMeanTimeValue = new Integer(fourthPanel.getIgnoreNBelowMeanTime());
	    }
	    if (!fourthPanel.getIgnoreNTimesAboveStandardDeviation().equals(BLANK)
		    && fourthPanel.getIgnoreNTimesAboveStandardDeviation() != null) {
		Integer ignoreNTimesAboveStandardDeviationValue = new Integer(fourthPanel.getIgnoreNAboveMeanTime());
	    }
	    if (!fourthPanel.getIgnoreNTimesBelowStandardDeviation().equals(BLANK)
		    && fourthPanel.getIgnoreNTimesBelowStandardDeviation() != null) {
		Integer ignoreNTimesBelowStandardDeviationValue = new Integer(fourthPanel.getIgnoreNBelowMeanTime());
	    }
	    if (!fourthPanel.getIgnoreNTimesAboveZScore().equals(BLANK)
		    && fourthPanel.getIgnoreNTimesAboveZScore() != null) {
		Integer ignoreNTimesAboveZScoreValue = new Integer(fourthPanel.getIgnoreNAboveMeanTime());
	    }
	    if (!fourthPanel.getIgnoreNTimesBelowZScore().equals(BLANK)
		    && fourthPanel.getIgnoreNTimesBelowZScore() != null) {
		Integer ignoreNTimesBelowZScoreValue = new Integer(fourthPanel.getIgnoreNBelowMeanTime());
	    }

	} else {
	    System.out.println("--->" + currentVisiblePanelId + "<---");
	}
    }
}
